package zachg.survival;

import java.awt.AlphaComposite;
import java.awt.Composite;
import java.awt.Graphics2D;

import com.threerings.util.Name;

/**
 * Displays a "potential move" cursor to the player.
 */
public class CursorSprite extends GameCharacterSprite
{
    public CursorSprite ()
    {
        super(new SurvivalObject.GameCharacter());
        _character.playerOwner = new Name( SurvivalObject.PLACEHOLDER_NAME );
        _comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
    }

    public void setPosition (int x, int y, Boolean isLegal)
    {
    	_character.x = x;
    	_character.y = y;
        _legal = isLegal;
    	updateGameCharacter(_character);
    }

    public SurvivalObject.GameCharacter getGameCharacter ()
    {
        return _character;
    }

    @Override // from GameCharacterSprite
    public void paint (Graphics2D gfx)
    {
        
        if (_legal) {
            Composite ocomp = gfx.getComposite();
            gfx.setComposite(_comp);
            super.paint(gfx);
            gfx.setComposite(ocomp);
        }
    }
  
    protected boolean _legal = false;
    
    protected AlphaComposite _comp;
}